<?php 
include dirname(dirname(__FILE__)).'/include/user-verify.php';
include_once dirname(dirname(__FILE__)).'/include/host-base.php';
require_once dirname(__FILE__).'/user-manage/functions.php';
include_once dirname(__FILE__).'/duty-table-show/functions.php';
$ex_user = getUserById($_SESSION['user_id']);
?>
<html>
	<head>
		<?php include dirname(dirname(__FILE__)).'/include/common-header.php'; ?>
		<script type="text/javascript" src="../js/menu_min.js"></script>
		<script type="text/javascript">
		function checkSession() {
			$.ajax({
				dataType:"text",
				url:'ajax/check-session.php',
				data:{},
				success:function(data) {
					if(data=='no') {
						alert("你离开时间过长，请重新登陆！");
						window.location='../login.php'; 
					}
				},
			});
		}
		$(document).ready(function(){
			setInterval(checkSession, 60000);
			$(".menu ul li").menu();
			$("#log-out-btn").click(function() {
				window.location=<?php echo '"'.getHost().'/log-out.php"'; ?>
			});
			$(".menu li a").click(function() {
				var goto = $.trim($(this).attr("goto"));
				if(goto!='') {
					$("#main-content").attr("src",goto);
				}
			});
			$("#exchange-redirect").click(function() {
				var goto = $.trim($(this).attr("goto"));
				if(goto!='') {
					$("#main-content").attr("src",goto);
				}
			});
			<?php
			if($ex_user['exchange_status']=='2') {
				$exchange_item = getExchangeByToUserId($_SESSION['user_id']);
				$from_user = getUserById($exchange_item['from_user_id']);
				echo 'alert("'.$from_user['user_real_name'].'向你发送了一个换班请求!");';
				echo '$("#exchange-redirect").click(function() {
						$(this).fadeOut();
					});';
			} else if($ex_user['exchange_status']=='3') {
				$exchange_item = getExchangeByFromUserId($_SESSION['user_id']);
				$from_user = getUserById($exchange_item['to_user_id']);
				echo 'alert("'.$from_user['user_real_name'].'同意了你的换班请求,现在请核实你的值班时间!");';
				echo '$("#main-content").attr("src","duty-table-show/show-duty-table.php");';
				clearExchangeStatus($_SESSION['user_id'],$exchange_item['id']);
			} else if($ex_user['exchange_status']=='4') {
				$exchange_item = getExchangeByFromUserId($_SESSION['user_id']);
				$from_user = getUserById($exchange_item['to_user_id']);
				echo 'alert("'.$from_user['user_real_name'].'拒绝了你的换班请求!");';
				clearExchangeStatus($_SESSION['user_id'],$exchange_item['id']);
			}
			?>


		});
		</script>
		<link rel="stylesheet" type="text/css" href="../css/menu/menu-css.css">
		<link rel="stylesheet" type="text/css" href="../css/menu/style.css"> 
		<link rel="stylesheet" type="text/css" href="css/style.css">
		<title>紫荆书屋后台管理系统</title>
	</head> 
	<body>
		<?php include dirname(__FILE__).'/header.php' ?> 
		<div class="row">
			<div class="menu col-md-4">
				<ul>
					<?php if($_SESSION['user_role']!='user')echo '<li><a>后台管理</a>
						<ul>
							<li><a goto="user-manage/index.php">员工管理</a></li>
							<li><a goto="user-manage/add-user-form.php">添加员工</a></li>
							<li><a goto="user-manage/user-worktime.php">查看员工工时</a></li>
							<li><a goto="duty-table-manage/index.php">值班表管理</a></li>
							<li><a goto="goods-manage/index.php">商品管理</a></li>
							<li><a goto="user-rule-manage/index.php">编辑员工守则</a></li>
							<li><a goto="excellent-worker-manage/index.php">编辑优秀员工</a></li>
							<li><a goto="sys-config-manage/index.php">系统设置</a></li>
							<li><a goto="employ-manage/index.php">招聘管理</a></li>
							<li><a goto="goods-sum-manage/index.php">录入报表</a></li>
							<li><a goto="goods-sum-manage/goods-form-show.php">查看报表</a></li>
							<li><a goto="place-apply-manage/index.php">场地申请</a></li>
							<li><a class="nav-click" href="javascript:void(0);" goto="aid-manage/aid-rule.php">资助流程编辑</a></li>
							<li><a goto="aid-manage/index.php">资助管理</a></li>
							<li><a class="nav-click" href="javascript:void(0);" goto="productions-manage/aid-rule.php">作品流程编辑</a></li>
							<li><a goto="productions-manage/index.php">作品管理</a></li>
							<li><a goto="announcement-manage/index.php">公告管理</a></li>
						</ul>			
					</li>'; ?>
					<li><a>个人信息管理</a>
						<ul>
							<li><a goto="personal-info-manage/index.php">个人信息查询</a></li>
							<li><a goto="personal-info-manage/personal-worktime.php">个人工时查询</a></li>
							<li><a goto="personal-info-manage/personal-info-edit.php">个人信息修改</a></li>
							<li><a goto="personal-info-manage/password-edit.php">登录密码修改</a></li>
						</ul>
					</li>
					<li><a>信息查询</a>
						<ul>
							<li><a goto="duty-table-show/show-duty-table.php">值班表查询</a></li>
							<li><a goto="user-rule-show/index.php">员工守则</a></li>	
							<li><a goto="contact-show/index.php">通讯录查询</a></li>		
							<li><a goto="excellent-worker-show/index.php">本月优秀员工</a></li>			
						</ul>
					</li>
					<li><a goto="duty-table-show/exchange-duty.php">请求换班</a></li>
					<li><a goto="admin-home.php">首页</a></li>
				</ul>
				</div>	
				<script type="text/javascript">
				 function SetCwinHeight(){
				  var iframeid=document.getElementById("main-content"); //iframe id
				  if (document.getElementById){
				   if (iframeid && !window.opera){
				    if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight){
				     iframeid.height = iframeid.contentDocument.body.offsetHeight+150;
				    }else if(iframeid.Document && iframeid.Document.body.scrollHeight){
				     iframeid.height = iframeid.Document.body.scrollHeight+150;
				    }
				    if(iframeid.height<document.documentElement.clientHeight)iframeid.height=document.documentElement.clientHeight;
				   }
				  }
				 }
				</script>
				<iframe class="col-md-8 col-md-offset-1" id="main-content" name="main-content"  
				onLoad="SetCwinHeight()"  scrolling="no" height="100%" src="admin-home.php" frameborder="0"   >
				</iframe>
		</div>
		 <?php include dirname(__FILE__).'/footer.php'; ?>
	</body>
</html>